from django.db import models
from userapp.models import User


# 设计 收货地址表

class Address(models.Model):
    receiver = models.CharField(max_length=20)
    province = models.CharField('省份', max_length=20)
    city = models.CharField('城市', max_length=20)
    district = models.CharField("县区", max_length=20)
    place = models.CharField(max_length=120)
    phone = models.CharField(max_length=11)
    tel = models.CharField(max_length=20, null=True, blank=True)
    user = models.ForeignKey(User, on_delete=models.CASCADE)
    default = models.BooleanField("是否是默认地址", default=False)

    class Meta:
        db_table = "addresses"


class ChinaCity(models.Model):
    areaid = models.AutoField(db_column='areaId', primary_key=True)  # Field name made lowercase.
    areacode = models.CharField(db_column='areaCode', max_length=50)  # Field name made lowercase.
    areaname = models.CharField(db_column='areaName', max_length=20)  # Field name made lowercase.
    level = models.IntegerField(blank=True, null=True)
    citycode = models.CharField(db_column='cityCode', max_length=50, blank=True,
                                null=True)  # Field name made lowercase.
    center = models.CharField(max_length=50, blank=True, null=True)
    parentid = models.IntegerField(db_column='parentId', blank=True, null=True)  # Field name made lowercase.

    class Meta:
        managed = False
        db_table = 'china_city'
